package com.tao.system.controller.question;

import com.tao.common.creo.controller.BaseController;
import com.tao.common.creo.domain.Result;
import com.tao.common.creo.domain.TableDataInfo;
import com.tao.system.domain.question.Question;
import com.tao.system.domain.question.dto.QuestionAddDTO;
import com.tao.system.domain.question.dto.QuestionEditDTO;
import com.tao.system.domain.question.dto.QuestionQueryDTO;
import com.tao.system.domain.question.vo.QuestionDetailVO;
import com.tao.system.domain.question.vo.QuestionVO;
import com.tao.system.service.question.IQuestionService;
import com.tao.system.service.question.impl.QuestionServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Tag(name = "题目接口", description = "该组是关于题目的操作的接口")
@Slf4j
@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Autowired
    IQuestionService iQuestionService;

    @Operation(summary = "获取题目列表")
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return  getTableDataInfo(iQuestionService.list(questionQueryDTO));
    }

    @PostMapping("/add")
    @Operation(summary = "添加题目")
    public Result<Void> add(@Validated @RequestBody QuestionAddDTO questionAddDTO) {
        return toResult(iQuestionService.add(questionAddDTO));
    }

    @Operation(summary = "获取题目信息")
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId) {
        return Result.success(iQuestionService.detail(questionId));
    }

    @PutMapping("/edit")
    public Result<Void> edit(QuestionEditDTO questionEditDTO) {
        return toResult((iQuestionService.edit(questionEditDTO)));
    }
    @DeleteMapping("/delete")
    public Result<Void> delete(Long questionId) {
            return toResult(iQuestionService.delete(questionId));
    }
}
